﻿using ITXHWEB.Models;
using ReflectionStudio.Core.Events;
using System;
using System.Data;
using System.Web.Mvc;
using WPFExcelReport;
using WPFExcelReport.Helpers;
using ITXHWEB.Infrastructure;
using System.Collections;
using System.Collections.Generic;
using System.Linq;

namespace ITXHWEB.Controllers
{
    public partial class WBBSTController : ITXController
    {
        [ChildActionOnly]
        public ActionResult SSTKQGEBNR(string returnUrl)
        {
            ModelState.Clear();
            return PartialView(MABF.CWBB);
        }
        [HttpPost]
        [AllowAnonymous]
        [ValidateAntiForgeryToken]
        public ActionResult SSTKQGEBNR(WBBSTModel model, string returnUrl)
        {
            try
            {
                OUTGEBNR(model);//从托盘中移除  
                ModelState.Clear();
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return RedirectToAction(MAPP, MAPP);
        }
        public void OUTGEBNR(WBBSTModel model)
        {
            if (model == null)
                return;
            if (model.WBBSTKNR == null)
                return;
            Helper.GetSTime(ref date, ref time, ref stime);
            MABF.CWBB.WBBSTKNR = Helper.Left(model.WBBSTKNR.PadRight(12), 12);
            dwData = VHP.VWBB.TBMain.NewRow();
            VHP.VWBB.SetUpNewRow(ref dwData);
            dwData["WBBMANDANT"] = app.Mandant;
            dwData["WBBSTKNR"] = MABF.CWBB.WBBSTKNR.PadRight(12);
            dwData["WBBAENDBEN"] = MABF.NEWUSER.PadRight(8);
            dwData["WBBAENDDAT"] = date.PadRight(8);
            dwData["WBBGEBNR"] = "".PadRight(8);
            VHP.VWBB.SETGEBNR(dwData, MABF.CWBB.LO, MABF.CWBB.LB, MABF.CWBB.LP, RUNID);
        }
    }
}
